package mgslangpack;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
public class Members
{
    public Members() throws Exception
    {
        final TextField tf1,tf2,tf3;
        Label l1,l2,l3;
        Button b1,b2,b3;
        final JFrame jf;
        jf=new JFrame("Member Menu");
        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jf.setSize(750,500);
        jf.setLayout(null);
        jf.setVisible(false);
        Container ctn=jf.getContentPane();
        ctn.setBackground(Color.LIGHT_GRAY);
        final TextArea ta = new TextArea();
        ta.setBounds(400,55,300,400);
        ta.setEditable(false);
        jf.add(ta);
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
	final Connection con = DriverManager.getConnection("jdbc:odbc:TheOZ_DB","","");
	Statement st = con.createStatement();
        ResultSet rs = st.executeQuery("SELECT Services.ServiceDescription,Services.ServiceRate,Services.BkReff FROM Services");
	while(rs.next())
        {
            String SDes,SID,SAv;
            SDes=rs.getString(1);
            SID=rs.getString(2);
            SAv=rs.getString(3);
            ta.append("\nService Description:\t"+ SDes+"\nServive Rate:\t\t"+SID+"\nRefference:\t\t"
                    +SAv+ "\n");
            ta.append(" ");
        }
        Font f1 = new Font("Lucida Handwriting",Font.BOLD,12);
        l1= new Label("Prefered DateD:");
        l1.setBounds(50,50,100,30);
        l1.setFont(f1);
        jf.add(l1);
        tf1 = new TextField();
        tf1.setBounds( 180,53,100,25);
        jf.add(tf1);        
        l2= new Label("Number of quest:");
        l2.setBounds(50,100,100,30);
        l2.setFont(f1);
        jf.add(l2);
        tf2 = new TextField();
        tf2.setBounds( 180,103,100,25);
        jf.add(tf2);        
        l3= new Label("Refference No:");
        l3.setBounds(50,150,100,30);
        l3.setFont(f1);
        jf.add(l3);
        tf3 = new TextField();
        tf3.setBounds( 180,153,100,25);
        jf.add(tf3);
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        DriverManager.getConnection("jdbc:odbc:TheOZ_DB","","");        
        b1 = new Button("Submit");
        b1.setBounds(190,280,80,30);
        b1.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e1)
            {
                try
                {
                    JOptionPane.showMessageDialog(null,"Thank you\n\n" +
                            "If you don’t hear from us within one working day," +
                            "\nsend another request.\n\nNow press \"Exit\"");
                    String s1,s2,s3;
                    s1=tf1.getText();
                    s2=tf2.getText();
                    s3=tf3.getText();
                    PreparedStatement ps = con.prepareStatement("insert into Bookings values(?,?,?)");
                    ps.setString(1,s1);
                    ps.setString(2,s2);
                    ps.setString(3,s3);
                    int i = ps.executeUpdate();
                    //JOptionPane.showMessageDialog(null,"Booked date Added");
                    tf1.setText("");
                    tf2.setText("");
                    tf3.setText("");
		}
		catch(Exception e2){}
            }
	}
        );
        jf.add(b1);               
        b2 = new Button("Back");
        b2.setBounds(120,340,80,30);
        b2.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e3)
            {
                try
                {
                    jf.hide();
                    new Menu();
                }
                catch(Exception e4){}
            }
        }
        );   
        jf.add(b2);
        b3 = new Button("Exit");
        b3.setBounds(50,400,80,30);
        b3.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e3)
            {
                try
                {
                     System.exit(0);
                }
                catch(Exception e4){}
            }
        }
        );
        jf.add(b3);
        jf.show();
    }         
}
/******************************************************************************/


